using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using Microsoft.SharePoint;
using Microsoft.LearningComponents;
using Microsoft.LearningComponents.Storage;
using Schema = Microsoft.LearningComponents.Storage.BaseSchema;
using Resources.Properties;

namespace Microsoft.SharePointLearningKit
{
    /// <summary>
    /// Represents the data in one column of one row of the results of a query generated by
    /// <c>QueryDefinition.CreateQuery</c>.  Specifically, represents the data of a cell that
    /// represents the name of a SharePoint Web site.  <c>WebNameRenderedCell</c> is based on
    /// <c>RenderedCell</c>.
    /// </summary>
    public class WebNameRenderedCell : RenderedCell
    {
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Private Fields
        //

        /// <summary>
        /// Holds the value of the <c>SPSiteGuid</c> property.
        /// </summary>
        [DebuggerBrowsable(DebuggerBrowsableState.Never)]
        Guid m_spSiteGuid;

        /// <summary>
        /// Holds the value of the <c>SPWebGuid</c> property.
        /// </summary>
        [DebuggerBrowsable(DebuggerBrowsableState.Never)]
        Guid m_spWebGuid;

        /// <summary>
        /// Holds the value of the <c>SPWebUrl</c> property.
        /// </summary>
        [DebuggerBrowsable(DebuggerBrowsableState.Never)]
        string m_spWebUrl;

        //////////////////////////////////////////////////////////////////////////////////////////////
        // Public Properties
        //

        /// <summary>
        /// Gets the GUID of the SharePoint site collection (<c>SPSite</c>) represented by this cell.
        /// </summary>
        public Guid SPSiteGuid
        {
            [DebuggerStepThrough]
            get
            {
                return m_spSiteGuid;
            }
        }

        /// <summary>
        /// Gets the GUID of the SharePoint Web site (<c>SPWeb</c>) represented by this cell.
        /// </summary>
        public Guid SPWebGuid
        {
            [DebuggerStepThrough]
            get
            {
                return m_spWebGuid;
            }
        }

        /// <summary>Whether to render as a link or not. Defaults to true.</summary>
        public bool RenderAsLink { get; set; }

        /// <summary>
        /// Gets the URL of the SharePoint Web site (<c>SPWeb</c>) represented by this cell.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
        public string SPWebUrl
        {
            [DebuggerStepThrough]
            get
            {
                return m_spWebUrl;
            }
        }

        //////////////////////////////////////////////////////////////////////////////////////////////
        // Internal Methods
        //

        /// <summary>
        /// Initializes an instance of this class.
        /// </summary>
        ///
        /// <param name="value">The value of the <c>Value</c> property.</param>
        ///
        /// <param name="sortKey">The value of the <c>SortKey</c> property.</param>
        ///
        /// <param name="id">The value of the <c>Id</c> property.</param>
        ///
        /// <param name="toolTip">The value of the <c>ToolTip</c> property.</param>
        ///
        /// <param name="wrap">The value of the <c>Wrap</c> property.</param>
        /// 
        /// <param name="spSiteGuid">The value of the <c>SPSiteGuid</c> property.</param>
        /// 
        /// <param name="spWebGuid">The value of the <c>SPWebGuid</c> property.</param>
        /// 
        /// <param name="spWebUrl">The value of the <c>SPWebUrl</c> property.</param>
        ///
        internal WebNameRenderedCell(object value, object sortKey, LearningStoreItemIdentifier id,
                string toolTip, bool wrap, Guid spSiteGuid, Guid spWebGuid, string spWebUrl) :
            base(value, sortKey, id, toolTip, wrap)
        {
            m_spSiteGuid = spSiteGuid;
            m_spWebGuid = spWebGuid;
            m_spWebUrl = spWebUrl;
            RenderAsLink = true;
        }
    }
}
